//获取应用实例
var api = require("../../api.js"),
app = getApp()

Page({
  data: {
    nodes: ''
  },
  onLoad: function() {
    this.getHtml();
    this.app = getApp();
  },
 
  //页面展示时，触发动画
  onShow: function () {
    //this.app.slideupshow(this, 'nodes', 200, 1)
  },
  getHtml() {
    let that = this;
    //显示动画
    wx.showNavigationBarLoading() //在标题栏中显示加载
    wx.request({
      url: api.active.act_preview_desc,
      header: {
        'content-type': 'application/json'
      },
      success(res) {
        if (res.statusCode == 200){
          let html = res.data.data;
          /** 设置标题 */
          wx.setNavigationBarTitle({
            title: '活动预览'
          })
          html = html.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display: inline-block;vertical-align: middle;" ')
          that.setData({
            nodes: html
          })
        }
      },
      complete: function (res) {
        //隐藏动画
        wx.hideNavigationBarLoading() ;
        wx.stopPullDownRefresh();//完成停止加载
      }
    })
  },

  /** 下拉刷新 */
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading(),
    console.log("下拉刷新"), 
    this.getHtml();
    setTimeout(function () {
      wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
    }, 1500);
  }
  
})